package com.sport.video.common.exception;

import java.util.HashMap;
import java.util.Map;

/**
* 自定义业务异常
*@Author Gred
*@Date 2019/3/1 11:03
*@version 1.0
**/
public class BusinessException extends RuntimeException {

	private static final long serialVersionUID = -1134955951203297180L;
	private Integer errorCode;
	private String errorMsg;
	/*** 异常返回时可能需要多带的额外信息 ***/
	private Map<String, Object> otherInfo;

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public BusinessException(String message) {
		super(message);
		this.errorMsg = message;
	}

	public BusinessException(Integer errorCode, String message) {
		super(message);
		this.errorCode = errorCode;
		this.errorMsg = message;
	}

	public BusinessException(String message, Integer errorCode, Throwable cause) {
		super(message, cause);
		this.errorCode = errorCode;
	}

	public BusinessException(String message, Throwable cause) {
		super(message, cause);
	}

	public BusinessException(Throwable cause) {
		super(cause);
	}

	public BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
		super(message, cause, enableSuppression, writableStackTrace);
	}

	public Integer getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(Integer errorCode) {
		this.errorCode = errorCode;
	}

	public Map<String, Object> getOtherInfo() {
		return otherInfo;
	}

	public void setOtherInfo(Map<String, Object> otherInfo) {
		this.otherInfo = otherInfo;
	}

	public void addOtherInfo(String key, Object value) {
		if (this.otherInfo == null) {
			this.otherInfo = new HashMap<String, Object>();
		}
		otherInfo.put(key, value);
	}

	public void addOtheInfos(Map<String, Object> infos) {
		if (this.otherInfo == null) {
			this.otherInfo = new HashMap<String, Object>();
		}
		otherInfo.putAll(infos);
	}
}
